﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 桌面相关;

public class CSharpDesktopPanelCreator
{
    // 获取桌面路径
    public static string GetDesktopPath()
    {
        return Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
    }

    // 创建面板文件夹
    public static void CreateDesktopPanel(string panelName)
    {
        string desktopPath = GetDesktopPath();
        string panelPath = Path.Combine(desktopPath, panelName);

        try
        {
            // 创建面板文件夹
            if (!Directory.Exists(panelPath))
            {
                Directory.CreateDirectory(panelPath);

                // 设置文件夹属性为系统文件夹（可选）
                File.SetAttributes(panelPath, File.GetAttributes(panelPath) | FileAttributes.System);

                MessageBox.Show($"已创建桌面面板: {panelName}", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("面板已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show($"创建面板失败: {ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}
